
import SettingAPI from '../api/setting.js';

export const Setting={
   state:{
      editSettingStatus:-1,     //插入状态 0失败  1成功  -1不改变
      settinginfo:[],
   },
   mutations:{
      setEditSettingStatus(state,status){
          state.editSettingStatus=status;
      },
      setSettingInfo(state,info){
          state.settinginfo=info;
      }
   },
   actions:{
      //插入Setting
      editSetting(context,data){
          SettingAPI.editSetting(data).then(function(response){
              context.commit('setEditSettingStatus',response.data.code);
          })
      },
      //获取详情
      loadSettingInfo(context,data){
          SettingAPI.getSettingInfo(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setSettingInfo',response.data.data.info);
              }
          })
      }
   },
   getters:{
      getEditSettingStatus:state=>{
          return state.editSettingStatus;
      },
      getSettingInfo:state => {
          return state.settinginfo;
      }
   }
}
